<html>
<head>
</head>
<body>
<div class="page-container">
    <div class="page-content">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="portlet light bordered">
                        <div class="portlet-title">
                            <div class="caption">
                              <span class="caption-subject font-green-sharp bold uppercase">
                              <i class="fa fa-gift"></i> 添加产品
                              </span>
                            </div>
                        </div>
                        <div class="portlet-body form">
                            <form action="javascript:;" id="updateForm" class="form-horizontal">
                                <div class="form-body">
                                    <div class="row">
                                        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
                                            <div class="form-group">
                                                <label class="col-md-2 col-sm-4 col-xs-4 control-label">产品编号：</label>
                                                <div class="col-md-8 col-sm-8 col-xs-8">
                                                    <div class="input-icon right">
                                                        <i class="fa"></i>
                                                        <input class="form-control" type="text" id="productId"
                                                               placeholder="请输入产品编号" name="productId" >
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
                                            <div class="form-group">
                                                <label class="col-md-2 col-sm-4 col-xs-4 control-label">产品名称：</label>
                                                <div class="col-md-8 col-sm-8 col-xs-8">
                                                    <div class="input-icon right">
                                                        <i class="fa"></i>
                                                        <input class="form-control" type="text" id="productName"
                                                               placeholder="请输入产品名称" name="productName" >
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
                                            <div class="form-group">
                                                <label class="col-md-2 col-sm-4 col-xs-4 control-label">产品类别：</label>
                                                <div class="col-md-8 col-sm-8 col-xs-8">
                                                    <select class="hasReward form-control" name="type"
                                                            id="type" >
                                                        <option value="">请选择</option>
                                                        <option value="1">文学</option>
                                                        <option value="2">哲学</option>
                                                        <option value="3">理工</option>
                                                        <option value="4">经济</option>
                                                        <option value="5">艺术</option>
                                                        <option value="6">政治</option>
                                                        <option value="7">其他</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12" id="nameHid" >
                                            <div class="form-group">
                                                <label class="col-md-2 col-sm-4 col-xs-4 control-label">作者：</label>
                                                <div class="col-md-8 col-sm-8 col-xs-8">
                                                    <input class="form-control" type="text" id="author"
                                                           placeholder="请输入作者" name="author" >
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
                                            <div class="form-group">
                                                <label class="col-md-2 col-sm-4 col-xs-4 control-label">出版社：</label>
                                                <div class="col-md-8 col-sm-8 col-xs-8">
                                                    <input class="form-control" type="text" id="press"
                                                           placeholder="请输入出版社" name="press" >
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
                                            <div class="form-group">
                                                <label class="col-md-2 col-sm-4 col-xs-4 control-label">定价：</label>
                                                <div class="col-md-8 col-sm-8 col-xs-8">
                                                    <input class="form-control" type="text" id="price"
                                                           placeholder="请输入定价（元）" name="price" >
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="text-right">
                                            <button type="button" class="btn green"
                                                    onclick="doAdd()">确认添加
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    jQuery(document).ready(function () {

    });
    function doAdd() {
        if ($("#productId").val()==''||$("#productId").val()==null){
            layer.msg("请输入产品编码！");return;
        }
        if ($("#productName").val()==''||$("#productName").val()==null){
            layer.msg("请选择产品名称！");return;
        }
        if ($("#author").val()==''||$("#author").val()==null){
            layer.msg("请输入作者！");return;
        }
        if ($("#press").val()==''||$("#press").val()==null){
            layer.msg("请选择出版社！");return;
        }
        if ($("#type").val()==''||$("#type").val()==null){
            layer.msg("请输入类别！");return;
        }
        if ($("#price").val()==''||$("#price").val()==null){
            layer.msg("请输入定价！");return;
        }
        if ($("#price").val() < 1){
            layer.msg("定价不能小于1！");return;
        }
        showMode();
        $.ajax({
            type: "POST",
            data: $('#updateForm').serializeArray(),
            url: rootPath + "/productManage/ajax/addProduct",
            dataType: 'json',
            success: function (data, textStatus) {
                if (data.code == '0000') {
                    parent.commonJs.alertMsg(data.msg, function () {
                        closeWindow();
                        closeMode();
                    });
                } else {
                    commonJs.alertMsg(data.msg, function () {
                        closeMode();
                    });
                }
            }
        });
    }
    function closeWindow(){
        window.parent.selectProductList();
        window.parent.layer.closeAll();
    }
</script>
</body>
</html>